
<!--这里是印厂子组件-->
<template>
    <div class="factory">
        <div class="container">
            <el-table :data="data"  style="width: 100%"   ref="multipleTable">
                <el-table-column prop="id" label="ID" width="80" align="center">
                </el-table-column>
                <el-table-column prop="post_name" label="职位名称" width="150" align="center">
                </el-table-column>
                <!-- <el-table-column prop="description" label="职位描述" width="350" align="center">
                </el-table-column> -->
                <el-table-column prop="salary_range" label="薪资" width="180" align="center">
                </el-table-column>
                 <el-table-column prop="city" label="招聘城市" width="320" align="center">
                </el-table-column>
                 <el-table-column prop="contactor" label="联系人" width="120" align="center">
                </el-table-column>
                  <!-- <el-table-column prop="nick_name" label="昵称" width="320" align="center">
                </el-table-column> -->
                <el-table-column prop="mobile" label="联系电话" width="120" align="center">
                </el-table-column>
                <el-table-column prop="created_time" label="发布时间" width="160" align="center">
                </el-table-column>
                <el-table-column prop="is_checked_text" label="审核状态" width="100" align="center">
                </el-table-column>
                <el-table-column label="操作" align="center" >
                    <template slot-scope="scope" >
                        <el-button class="edit" size="small" type="text" @click="handleLook(scope.$index, scope.row)">查看</el-button>
                        <el-button class="del" size="small" type="text"  @click="handleCheck(scope.$index, scope.row)" v-show="scope.row.status==0">审核</el-button>
                    </template>
                </el-table-column>
            </el-table>

             <!-- 审核操作弹出界面 -->
            <el-dialog title="审核" :visible.sync="isChecked"  center width="450px">
                <el-form style="width:400px; margin:0 auto">
                    <el-form-item label="招聘职位：">
                        {{listData.post_name}}
                    </el-form-item>
                    <!-- <el-form-item label="职位描述“">
                         {{listData.description}}
                    </el-form-item> -->
                    <el-form-item label="薪资：">
                         {{listData.salary_range}}
                    </el-form-item>
                     <el-form-item label="招聘城市：">
                         {{listData.city}}
                    </el-form-item>
                    <el-form-item label="联系人：">
                         {{listData.contactor}}
                    </el-form-item>
                     <el-form-item label="联系电话：">
                         {{listData.mobile}}
                    </el-form-item>
                    <el-form-item label="审核状态：">
                        <div>
                            <el-radio v-model="state" label="1" border>审核不通过</el-radio>
                            <el-radio v-model="state" label="2" border>审核通过</el-radio>
                        </div>
                    </el-form-item> 
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="isChecked = false">取 消</el-button>
                    <el-button type="primary" @click="confirmCheck">确 定</el-button>
                </div>
            </el-dialog>
        </div>
    </div>
</template>
<script>
import {getpubCheckList,postCheckPublish,} from '@/api/check/publish'
export default {
    name:"recruit",
    props:{
        data:Array,
        isFlagL:Boolean,
    },
    data() {
        return {
            delVisible:false, //默认dialog 不弹出
            isChecked:false,//审核界面默认隐藏 true显示
            id:'',//当前对象id
            state:'1',//审核状态：0审核中，1审核不通过，2审核通过
            listData:[],//操作对象数据
            type:3,//类型 发布分类：1印厂,2设备,3招聘,4供应,5求购,6心情
        }
    },
    //实例创建
    created(){
        //
        // this.getDate();
    },
    //计算属性
    computed:{

    },
    //方法
    methods: {
        //获取数据
        getData(){
            getpubCheckList('',this.type,'','',1,99999999).then((response)=> {
                console.log(response);
                if(response.code==200){
                    var data = response.data.list;//当前返回的数据
                    //遍历数据取详情
                    for(let i=0;i<data.length;i++){
                        if(data[i].id == this.id){//找到了
                            this.listData = data[i];

                        }
                    }
                }else{
                    this.$notify.error({
                        title: '异常',
                        offset: 100,
                        message: response.msg
                    });
                }
            })
        },    
        //发布
        urlAdd(){
            this.$router.push({ path:'/substation/add'})
        },
        //查看详情
        handleLook(index,row){
            if(row.id && row.id>0){
                //跳转到详情页
                this.$router.push({ path: '/recruit/details',query:{id:row.id}});
            }
        },
        //去审核（显示审核界面）
        handleCheck(index,row){
            console.log(index,row);
            if(row.id && row.id>0){
                this.id = row.id; //当前对象id
                this.getData();
                this.isChecked = true; //显示兑换弹出框
            }
        },
        // 确定提交审核
        confirmCheck(){
            let _this = this;
            if(this.id>0){
                // console.log(_this.id)
                postCheckPublish(_this.id,_this.type,_this.state).then(response=>{
                    // console.log(response);
                    if(response.code==200){
                        _this.$message.success('操作成功');
                        _this.isChecked = false;
                        _this.isFlagL = true;
                                _this.$emit('run') 
                        
                    }else{
                        _this.$notify.error({
                            title: '操作失败',
                            duration:2000,
                            message: '失败原因：'+response.data.msg
                        });
                    }
                    
                })
            }
            
        }
        
    }
}
</script>
<style lang="stylus" scoped>
    .edit{
        color #ff9800;
    }
    .del{
        color #e51c23;
    }
    .download{
        color #67C23A;
    }
</style>


